0 1 00:00:00,560 --> 00:00:01,220 Hey there. 1 2 00:00:01,250 --> 00:00:07,190 I've got a simple practice activity here that I'd like for you to attempt to solve regarding if statements. 2 3 00:00:07,550 --> 00:00:11,750 You're going to create a variable here and you're going to call it weather and set it to a string like 3 4 00:00:11,750 --> 00:00:12,650 overcast. 4 5 00:00:13,010 --> 00:00:17,690 Using this variable, I'd like for you to create an if statement to check if the variable is equivalent 5 6 00:00:17,690 --> 00:00:18,740 to another string. 6 7 00:00:18,740 --> 00:00:22,130 So if it's snowing out, then print into the console. 7 8 00:00:22,160 --> 00:00:23,540 Today is a cold day. 8 9 00:00:23,780 --> 00:00:25,700 If it's rainy out, then print. 9 10 00:00:25,700 --> 00:00:27,500 Grab an umbrella, it's raining. 10 11 00:00:27,590 --> 00:00:29,240 If it's overcast, then print. 11 12 00:00:29,240 --> 00:00:30,470 Today is cloudy. 12 13 00:00:30,500 --> 00:00:34,460 Otherwise, if none of those evaluated are true, then you can print. 13 14 00:00:34,460 --> 00:00:35,780 It's a nice sunny day. 14 15 00:00:36,350 --> 00:00:41,150 So please pause the video and take a minute or two to solve and finish this activity. 15 16 00:00:41,390 --> 00:00:43,730 I'll show you my solution in a little bit. 16 17 00:00:45,820 --> 00:00:49,540 Okay, So to solve this problem, I'm going to create a variable here. 17 18 00:00:50,650 --> 00:00:51,580 Call it weather. 18 19 00:00:52,880 --> 00:00:55,460 And I'll set the string to be overcast. 19 20 00:00:56,620 --> 00:01:01,360 Next, I'll create a new if statement and pass my weather variable. 20 21 00:01:03,010 --> 00:01:06,450 And then using the operator we saw earlier to compare equivalence, 21 22 00:01:06,460 --> 00:01:10,780 I'll check to see if the string is equal to snowing. 22 23 00:01:13,210 --> 00:01:14,680 If so, we'll print. 23 24 00:01:15,620 --> 00:01:17,630 Today is a cold day. 24 25 00:01:21,430 --> 00:01:24,790 Else if the weather is equivalent to raining. 25 26 00:01:27,530 --> 00:01:28,490 Then we'll print. 26 27 00:01:30,710 --> 00:01:32,090 Grab an umbrella. 27 28 00:01:33,670 --> 00:01:34,750 It's raining. 28 29 00:01:36,170 --> 00:01:38,750 Else if the weather is overcast. 29 30 00:01:42,140 --> 00:01:43,190 Then we'll print. 30 31 00:01:43,370 --> 00:01:45,350 Today is cloudy. 31 32 00:01:47,090 --> 00:01:49,310 And lastly, we'll use else here. 32 33 00:01:50,060 --> 00:01:51,100 And just print. 33 34 00:01:51,110 --> 00:01:52,940 It's a nice sunny day. 34 35 00:01:54,230 --> 00:01:56,930 When all the other conditions did not evaluate to true. 35 36 00:01:57,820 --> 00:02:02,290 Now we can run our game and see if the results we get are the ones we expect. 36 37 00:02:03,950 --> 00:02:04,580 Great. 37 38 00:02:05,060 --> 00:02:10,460 Now we can end the test and continue changing this variable to check the other parts of our if statement. 38 39 00:02:12,760 --> 00:02:20,170 So I'll just change the value here to be snowing and then we can test to see if we get. 39 40 00:02:20,170 --> 00:02:22,210 Today is a cool day and we do. 40 41 00:02:23,330 --> 00:02:26,840 Let me end the test and then I'll change it to. 41 42 00:02:28,140 --> 00:02:32,880 Partly cloudy and see if we get the message. 42 43 00:02:32,880 --> 00:02:35,880 It's a nice sunny day and we do. 43 44 00:02:36,450 --> 00:02:37,230 Excellent.